const Router = require('koa-router');
const router = new Router();

// 验证身份
const { authMiddleware, authorizeAdmin } = require('../middlewares/authMiddleware')
// 业务层
const {
  createLog,
  getAllLogs,
  getLogById,
  updateLog,
  deleteLog,
  deleteLogs,
} = require('../controllers/logController')

// 创建日志
router.post('/', authMiddleware, createLog);

// 获取所有日志
router.get('/', authMiddleware, authorizeAdmin, getAllLogs);

// 获取单个日志
router.get('/:logId', authMiddleware, authorizeAdmin, getLogById);

// 更新日志
router.put('/:logId', authMiddleware, authorizeAdmin, updateLog);

// 删除单个日志
router.delete('/:logId', authMiddleware, authorizeAdmin, deleteLog);

// 批量删除日志
router.delete('/', authMiddleware, authorizeAdmin, deleteLogs);

module.exports = router;